//===================================================
//作    者：边涯  http://www.u3dol.com
//创建时间：2020-08-05 19:19:54
//备    注：
//===================================================
//using YouYouServer.Core;
using System;
using System.Collections.Generic;

/// <summary>
/// 服务器返回心跳
/// </summary>
public struct System_hearbeatReturnProto : IProto
{
    public ushort ProtoCode => 14002;
    public string ProtoEnName => "System_hearbeatReturn";
    //public ProtoCategory Category => ProtoCategory.WorldServer2Client;

    public float LocalTime; //客户端发送的本地时间
    public long ServerTime; //服务器时间（毫秒）

    public byte[] ToArray(MMO_MemoryStream ms, bool isChild = false)
    {
        ms.SetLength(0);
        if (!isChild)
        {
            ms.WriteUShort(ProtoCode);
            //ms.WriteByte((byte)Category);
        }

        ms.WriteFloat(LocalTime);
        ms.WriteLong(ServerTime);

        return ms.ToArray();
    }

    public static System_hearbeatReturnProto GetProto(MMO_MemoryStream ms, byte[] buffer)
    {
        System_hearbeatReturnProto proto = new System_hearbeatReturnProto();
        ms.SetLength(0);
        ms.Write(buffer, 0, buffer.Length);
        ms.Position = 0;

        proto.LocalTime = ms.ReadFloat();
        proto.ServerTime = ms.ReadLong();

        return proto;
    }
}